import * as hardwareService from '../../services/hardware'; 
import { qryAllUser } from '../../services/user';    
export default {
  namespace: 'hardware',
  state: {    
    loading: false,
    list: [],  
    current: 1,
    currentSize: 10,
    total: 0,   
  },
  reducers: {        
    upState(state, { payload }) {
      return { ...state, ...payload }
    },

    
  },
  effects: {
   
    *queryList({ payload }, { call, put }) { 
      const { body } = yield call(hardwareService.queryList, payload);  
      yield put({ type: 'upState', payload: { list: body.data, current: body.current, currentSize: body.size, total: body.iTotalRecords } });
    },

    *reload(action, { put }) {
      yield put({ type: 'queryList', payload: { 'name': '' } });
    },

 

  },
 
  subscriptions: {
    setup({ dispatch, history }) {
      return history.listen(({ pathname }) => { 
        if (pathname === '/hard/hardware') { 
          dispatch({ type: 'queryList', payload: { 'status': '' } });
        }
      });
    },
  },
};
